use std::process::Command;
use actix_web::{App, get, HttpServer, Responder, web};

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new().service(greet)
    })
        .bind(("0.0.0.0", 8080))?
        .run()
        .await
}

#[get("/sleep")]
async fn greet() -> impl Responder {
    Command::new("cmd")
        .args(&["/C", "%windir%\\System32\\rundll32.exe powrprof.dll,SetSuspendState 0,1,0"])
        .output()
        .expect("Failed to execute command");

    "Hello!".to_string()
}